package com.demo12;

import java.util.TreeSet;

public class TreeSetDemo2 {
    public static void main(String[] args) {
        //实例化一个TreeSet类方法
        TreeSet<Students> treeSet = new TreeSet<>();

        //实例化学生类
        Students s1 = new Students("xishi", 23);
        Students s2 = new Students("wangzhaojun", 25);
        Students s3 = new Students("diaochan", 27);
        Students s4 = new Students("yangyuhuan", 22);
        Students s5 = new Students("wuzetian", 22);

        //添加集合信息数据
        treeSet.add(s1);
        treeSet.add(s2);
        treeSet.add(s3);
        treeSet.add(s4);
        treeSet.add(s5);

        for (Students s: treeSet){
            System.out.println(s.getName()+"-------"+s.getAge());
        }
    }
}
